/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

//import com.etfbl.net.dao.DAOUSER;
//import com.etfbl.net.dto.USER;
import com.etfbl.net.dao.DAOUSER;
import com.etfbl.net.dto.USER;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Scanner;

/**
 *
 * @author abosancic
 */
public class JavaTest {

    public static void main(String[] args) throws
            ClassNotFoundException, SQLException, Exception {

        DAOUSER per = new DAOUSER();
//        
//        USER uu = new USER();
//        uu.setId(per.getLast().getId() + 1);
//        uu.setName("Tomo");
//        uu.setPassword("Pasword");
//        per.save(uu);
//        
//        uu = per.getFirst();
//        uu.setName("OSAM");
//        per.update(uu);
//        
//        uu.setId(8);
//        per.remove(uu);
//        
        while (true) {

            new Scanner(System.in).next();
            List<USER> liu = per.findAll();
            System.out.println(" " + liu.size());

            for (USER user : liu) {
                System.out.println("" + user);
            }

            liu = per.query("select * from USER");
            for (USER user : liu) {
                System.out.println("" + user);
            }
            
            ResultSet res = per.selectResultSet("select * from USER");
            while (res.next()) {
                USER u = new USER();
                u.setId(res.getInt(1));
                u.setPassword(res.getString(3));
                liu.add(u);
            }

            for (USER user : liu) {
                System.out.println("" + user);
            }
            
            res.close();
        }
    }
}